package com.java.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author: wjr
 * @Description:
 * @Date Created in  2020-09-02 23:57
 * @Modified By:
 */
@WebServlet(value = "/loginOut")
public class loginOutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
//        session.removeAttribute("user");//让指定名称的session失效
        session.invalidate();//让所有的session失效
        resp.sendRedirect("index.jsp");//跳转到登录页面
    }
}
